<?php

// Is used to make log in logme.txt
function logme($str) { //return;
  static $fd = false;
  if ($fd === false) {
    $fd = fopen('logme.txt', 'a');
  }
//  fprintf($fd, "%s: %s %d\n", date('r'), $str, mt_rand());
  fprintf($fd, "%s: %s\n", date('r'), $str);
}

// used to evaluate the time difference betweeen
// two functions
function timer($label) { //return;
  static $stamp = false;
  if ($stamp === false) {
    $stamp = microtime(true);
    return;
  }
  $current = microtime(true);
  logme(sprintf('timer %s : %f ms', $label, round(($current - $stamp) * 1000, 2)));
  $stamp = $current;
}

/*
$fd = fopen('logme.txt', 'a');
Here $fd is resource of "logme.txt"
*
* OR we can say $fd is file haandler
*
* we will do all the further operations with the help of $fd(file handler)
*
*
* means it contain all the data of "logme.txt"
* There re several Modes of File I/O
* a => append
* r => read
* w => read/write
*
* if any one of above option is used with + sign
* theen it means it is trying to create file if
* file not found
*
* w+ it will try to create file if file not found
*
*
'r' => Open for reading only; place the file pointer at the beginning of the file.

'r+' => Open for reading and writing; place the file pointer at the beginning of the file.
*
'w' =>Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
*
*
'w+' => Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
*
'a' =>Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
**/
















